package lcr;

import java.util.Arrays;

public class Test0016 {
}

class Solution0016_1 {
    public int lengthOfLongestSubstring(String s) {
        int l=0,ans=0,len=s.length();
        int[] records = new int[128];
        char[] charArray = s.toCharArray();
        Arrays.fill(records,-1);
        for (int r = 0; r < len; r++) {
            int c=charArray[r];
            l=Math.max(records[c]+1,l);
            records[c]=r;
            ans=Math.max(ans,r-l+1);
        }

        return ans;
    }

}
